﻿using System;
using fastCSharp;

namespace diantou.web.onlineJudge
{
    /// <summary>
    /// 话题问题列表
    /// </summary>

    [fastCSharp.code.cSharp.webView(IsPool = true, IsReferer = false)]
    partial class topicProblem : topic.view<topicProblem>
    {
        /// <summary>
        /// 话题集合
        /// </summary>
        internal static readonly diantou.dataAccess.topic[] Topics = diantou.dataAccess.problem.TopicIds.getArray(value => (diantou.dataAccess.topic)diantou.dataAccess.tcpCall.topic.Get(value))
            .toCollection().addExpand(diantou.dataAccess.problem.NullTopic).toArray();


        /// <summary>
        /// 问题列表
        /// </summary>
        [fastCSharp.emit.webView.clearMember]
        private userProblem[] problems;
        /// <summary>
        /// 分组菜单
        /// </summary>
        private groupMenu groupMenu
        {
            get { return new groupMenu { ViewOnly = requestHeader.IsReView, IsTopic = true }; }
        }
        /// <summary>
        /// 初始化问题列表
        /// </summary>
        /// <param name="topicId">话题标识</param>
        /// <param name="page">分页号</param>
        /// <param name="sort">排序类型</param>
        /// <param name="isAsc">是否升序</param>
        /// <returns>是否成功</returns>
        private bool loadView(int topicId, int page, diantou.dataAccess.problem.sort sort, bool isAsc)
        {
            if ((topic = diantou.dataAccess.tcpCall.topic.Get(topicId)) == null)
            {
                topic = diantou.dataAccess.problem.NullTopic;
                query.topicId = 0;
            }
            diantou.dataAccess.problem[] values = diantou.dataAccess.clientCache.Problem.Get(diantou.dataAccess.tcpCall.problem.getIdsByTopic(topicId, sort, isAsc, pageInfo.Size = 20, pageInfo.Page = page, currentUserId, out pageInfo.Count));
            problems = values.getArray(value => new userProblem { Problem = value, User = currentUser });
            if (requestHeader.IsSearchEngine) pageInfo.Path = topic.Path.ProblemList.ToPageString();
            return true;
        }
    }
}
